package com.wlwk.controller;

import com.wlwk.common.exception.RRException;
import com.wlwk.common.exception.menu.RespCode;
import com.wlwk.common.exception.util.RespResult;
import com.wlwk.common.yidong.ChangZhouUrl;
import com.wlwk.model.plat.QueryRealTimeGPRS;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("api")
public class ApiController {

    /**
     * 获取本月的总平台的流量使用情况
     * @return
     */
    @GetMapping(value = "/getNowPlatformGprs",produces = MediaType.APPLICATION_JSON_VALUE)
    public QueryRealTimeGPRS getNowPlatformGprs(){
        QueryRealTimeGPRS res = ChangZhouUrl.openQryInternetGrpPoolGprs();
        return  res;
    }

    /**
     * 根据卡号查询流量信息
     * @param number
     * @return
     */
    @GetMapping(value = "/qryInternetUserGprs",produces = MediaType.APPLICATION_JSON_VALUE)
    public RespResult qryInternetUserGprs(String number, String ebid){
        try {
            String res = ChangZhouUrl.qryInternetUserGprs(number,ebid);
            return  RespResult.ok(res);
        } catch (Exception e) {
            throw new RRException("9000",e.getMessage());
        }
    }

}
